package b4.config
{
	public class LayerItemConfigCreature extends LayerItemConfig
	{
		public var creatures:Object;
		
		public function LayerItemConfigCreature(itemStrs:Array=null)
		{
			super(itemStrs);
			creatures = new Object();
			if (itemStrs != null)
			{
				var creatureStrs:Array = itemStrs[2].split(" ");
				for (var i:int = 0; i < (creatureStrs.length  - 1) / 4; i++)
				{
					var creaturePos:LayerItemConfigCreaturePos = new LayerItemConfigCreaturePos();
					creaturePos.index = parseInt(creatureStrs[4 * i]);
					creaturePos.num = parseInt(creatureStrs[4 * i + 1]);
					creaturePos.position = parseInt(creatureStrs[4 * i + 2]);
					creaturePos.isBoss = Boolean(parseInt(creatureStrs[4 * i + 3]));
					creatures[creaturePos.position] = creaturePos;
				}
			}
		}
		
		override public function serializeExport():String
		{
			var serialStr:String = super.serializeExport() + ",";
			for (var posStr:String in creatures)
			{
				var creaturePos:LayerItemConfigCreaturePos = creatures[posStr];
				serialStr += creaturePos.serializeExport() + " "; 
			}
			return serialStr;
		}
		
	}
}